/*************************************
 * FILE : Ov7620.h
 * Description: Initial register of OV7620 CIS.
 * History:
 *	119/xx/2002	for 2420. S.J.Lee
 *************************************/

#define CAM_ID			(0x42)
#define	CAM_HSIZE		(664)
#define	CAM_VSIZE		(492)
#define	CAM_ACT_HSIZE	(640)	// Max 640
#define	CAM_ACT_VSIZE	(480)	// Max 480
#define	CAM_STX		(0x2f)	//47
#define	CAM_STY		(6)		//6
#define	CAM_ENDX		(((CAM_ACT_HSIZE)/4) + CAM_STX)
#define	CAM_ENDY		((CAM_ACT_VSIZE/2) + CAM_STY-1)


const unsigned char Ov7620_Rgb8bit[][2] = {
	{0x12, 0x80},		// Camera Soft reset. Self cleared after reset.
	{0x00, 0x00},		// gain
	{0x01, 0x80},		// set blue gain
	{0x02, 0x80},		// set red gain
	{0x06, 0x80},		// set brightness
	{0x0c, 0x24},		// set blue background
	{0x0d, 0x24},		// set red background
	{0x10, 0xb0},		// set exposure time, default:ff *************** when 80: so dark
	{0x11, 0x41},		// set frame rate, 27Mhz/(0+1)=27MHz
	{0x12, 0x6e},		// set RGB mode, enable AGC and AWB, mirror image
	{0x13, 0x01},		// 8-bit data format, Enable auto adjust mode
	{0x14, 0x94},		//QVGA format 640x480, GAMMA on.
	{0x15, 0x01},		// Use PCLK rising edge to latch data, UVUV(16-bit), UYVY(8-bit)
	{0x16, 0x03},		//

	{0x17, CAM_STX	},	//
	{0x18, CAM_ENDX	},	// (207-47)*4 = 640
	{0x19, CAM_STY	},	//
	{0x1a, CAM_ENDY	},	// ((244-5)+1)*2=480

	{0x1b, 0x00},		// pixel shift
	{0x20, 0x00},		//
	{0x21, 0x80},		//
	{0x22, 0x80},		//
	{0x23, 0x00},		//
	{0x28, 0xa2},		// 1-Line, Progressive mode.
	{0x24, 0x10},		// 3a
	{0x25, 0x8a},		// 60
	{0x26, 0xa2},		//
	{0x27, 0xe2},		//
	{0x29, 0x00},		//
	{0x2a, 0x00},		// frame rate high, 60Hz, 50Hz:0x80
	{0x2b, 0x00},		// frame rate low, 60Hz, 50Hz:0xac
	{0x2c, 0x88},		//
	{0x2d, 0x85},		//
	{0x2e, 0x80},		//
	{0x2f, 0x44},		//
	{0x60, 0x27},		//
	{0x61, 0x02},		// 0a
	{0x62, 0x5f},		//
	{0x63, 0xd5},		//
	{0x64, 0x57},		// Disable Y Gamma
	{0x65, 0x83},		//
	{0x66, 0x55},		//
	{0x67, 0x92},		//

	{0x68, 0xca},		//
	{0x69, 0x76},		//
	{0x6a, 0x22},		//
	{0x6b, 0x00},		//
	{0x6c, 0x08},		//
	{0x6d, 0x48},		//
	{0x6e, 0x80},		//
	{0x6f, 0x0c},		//
	{0x70, 0x89},		//
	{0x71, 0x00},		//
	{0x72, 0x14},		//
	{0x73, 0x54},		//
	{0x74, 0x20},		//
	{0x75, 0x0e},		//
	{0x76, 0x00},		//
	{0x77, 0xff},		//
	{0x78, 0x80},		//
	{0x79, 0x80},		//
	{0x7a, 0x80},		//
	{0x7b, 0xe6},		//
	{0x7c, 0x00},		//
	{0x06, 0x60},		//

	{0x12, 0x6C}		// set RGB mode, enable AGC and AWB, mirror image

};


const unsigned char Ov7620_Yuv16bit[][2] = {

	{0x12, 0x80},			// Camera Soft reset. Self cleared after reset.
	{0x17, CAM_STX},		//
	{0x18, CAM_ENDX},	// (207-47)*4 = 640
	{0x19, CAM_STY},		//
	{0x1a, CAM_ENDY},	// ((244-5)+1)*2=480

	{0x01, 0x80},		// set blue gain
	{0x02, 0x80},		// set red gain
	{0x03, 0xb0},
	{0x06, 0x70},		// set brightness
	{0x07, 0x00},
	{0x0c, 0x24},		// set blue background
	{0x0d, 0x24},		// set red background
	{0x10, 0xff},		// set exposure time, brightness control
	{0x11, 0x40},		// set frame rate 27Mhz/[(0+1)*2]=13.5MHz
	{0x12, 0x24},		// set YUV mode, enable AGC/AWB, mirror image.
	{0x15, 0x01},		// Use PCLK rising edge to latch data
	{0x16, 0x03},		//
	{0x12, 0x64},		// set YUV mode, enable AGC/AWB, mirror image.
	{0x13, 0x01},		// YUV 16-bit format, Disable AEC/AGC/AWB
	{0x14, 0x84},		// turn off GAMMA
	{0x24, 0x3a},		//
	{0x25, 0x60},		//
	{0x28, 0x20},		// Progressive mode.
	{0x2d, 0x95},		//
	{0x67, 0x92},		//
	{0x74, 0x00}		//
};

const unsigned char Ov7620_YCbCr8bit[][2] = {

	{0x12, 0x80},			// Camera Soft reset. Self cleared after reset.
	{0x00, 0x00},
	{0x01, 0x80},		// set blue gain
	{0x02, 0x80},		// set red gain
	{0x03, 0xb0},
	{0x06, 0x60},		// set brightness
	{0x0c, 0x24},		// set blue background
	{0x0d, 0x24},		// set red background
	{0x10, 0xff},		// set exposure time, brightness control
	{0x11, 0x80},		// set frame rate CLK_input = PCLK
	{0x12, 0x34},		// set 8 Bit YUV mode, enable AGC/AWB, mirror image.
	{0x15, 0x01},		// Use PCLK falling edge to latch data, 8 Bit UYVY....
	{0x16, 0x03},		//
	{0x17, 0x2f},		//
	{0x18, 0xcf},	// (207-47)*4 = 640
	{0x19, 0x06},		//
	{0x1a, 0xf5},	// ((244-5)+1)*2=480
	{0x1b, 0x00},
	{0x20, 0x00},
	{0x21, 0x80},
	{0x22, 0x80},
	{0x23, 0x00},
	{0x26, 0xa2},
	{0x27, 0xea},
	{0x29, 0x00},
	{0x2a, 0x00},
	{0x2b, 0x00},
	{0x2c, 0x88},
	{0x2e, 0x80},
	{0x2f, 0x44},
	{0x60, 0x27},
	{0x61, 0x82},
	{0x62, 0x5f},
	{0x63, 0xd5},
	{0x64, 0x57},
	{0x65, 0x83},
	{0x66, 0x55},
	{0x68, 0xcf},
	{0x69, 0x76},
	{0x6a, 0x22},
	{0x6b, 0x00},
	{0x6c, 0x08},
	{0x6d, 0x48},	
	{0x6e, 0x80},
	{0x6f, 0x0c},
	{0x70, 0x89},
	{0x71, 0x00},
	{0x72, 0x14},
	{0x73, 0x54},	
	{0x75, 0x0e},
	{0x76, 0x00},
	{0x77, 0xff},
	{0x78, 0x80},
	{0x79, 0x80},
	{0x7a, 0x80},
	{0x7b, 0xe6},
	{0x7c, 0x00},	
	{0x13, 0x21},
	{0x14, 0x94},	
	{0x24, 0x10},
	{0x25, 0x8a},

	{0x12, 0x34}		// set 8 Bit YUV mode, enable AGC/AWB, mirror image.
};

/*
const unsigned char Ov7620_YCbCr8bit[][2] = {

	{0x12, 0x80},			// Camera Soft reset. Self cleared after reset.
	{0x17, CAM_STX},		//
	{0x18, CAM_ENDX},	// (207-47)*4 = 640
	{0x19, CAM_STY},		//
	{0x1a, CAM_ENDY},	// ((244-5)+1)*2=480

	{0x01, 0x40},		// set blue gain
	{0x02, 0x40},		// set red gain
//	{0x01, 0x80},		// set blue gain
//	{0x02, 0x80},		// set red gain

	{0x03, 0xb0},
	{0x06, 0x60},		// set brightness
//	{0x06, 0x70},		// set brightness

	{0x07, 0x00},
	{0x0c, 0x24},		// set blue background
	{0x0d, 0x24},		// set red background
	{0x10, 0xff},		// set exposure time, brightness control
	{0x11, 0x80},		// set frame rate CLK_input = PCLK
//	{0x11, 0x40},		// set frame rate 27Mhz/[(0+1)*2]=13.5MHz

	{0x12, 0x34},		// set 8 Bit YUV mode, enable AGC/AWB, mirror image.
//	{0x12, 0x24},		// set YUV mode, enable AGC/AWB, mirror image.	

	{0x15, 0x01},		// Use PCLK falling edge to latch data, 8 Bit UYVY....
	{0x16, 0x03},		//

//	{0x12, 0x64},		// set YUV mode, enable AGC/AWB, mirror image.

	{0x13, 0x21},		// YUV 16-bit format, Disable AEC/AGC/AWB
//	{0x13, 0x01},		// YUV 16-bit format, Disable AEC/AGC/AWB	

	{0x14, 0x94},		// turn off GAMMA
//	{0x14, 0x84},		// turn off GAMMA

	{0x24, 0x10},		//
//	{0x24, 0x3a},		//
	
	{0x25, 0x8a},		//
//	{0x25, 0x60},		//	

	{0x28, 0x20},		// Progressive mode.
	{0x2d, 0x95},		//
	{0x67, 0x92},		//
	{0x74, 0x00}		//
};
*/
